package cn.hxzy.Controller;


import cn.hxzy.common.R;
import cn.hxzy.entity.Train;
import cn.hxzy.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;


@RestController
@RequestMapping("/order")
public class OrdersController extends BaseController{
    @Autowired
    private OrdersService ordersService;

    @PostMapping("/addOrder")
    public R addOrder(@RequestBody Train train){
        String userName = claim.asString();
        if (StringUtils.isEmpty(userName)){
            return R.error().message("未登录");
        }
        return ordersService.addOrder(train,userName);
    }

}

